#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/ant.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

DEB_COMPRESS_EXCLUDE := .pdf
JAVA_HOME_DIRS       := /usr/lib/jvm/java-6-openjdk
DEB_ANT_BUILDFILE    := weka/build.xml
DEB_ANT_BUILD_TARGET := exejar docs
DEB_JARS             := cup JFlex

install/weka::
	install -m644 -D dist/weka.jar debian/weka/usr/share/java/weka-$(DEB_UPSTREAM_VERSION).jar
	dh_link -pweka /usr/share/java/weka-$(DEB_UPSTREAM_VERSION).jar /usr/share/java/weka.jar

build/weka-doc:: debian/stamp-build-weka-doc
debian/stamp-build-weka-doc:
	# bayes
	( cd wekadocs/bayesnet && \
	latex bayesnet.tex ; latex bayesnet.tex ;\
	dvipdf bayesnet.dvi )
	# experimenter
	( cd wekadocs/experimentertutorial && \
	latex tutorial.tex ; latex tutorial.tex ;\
	dvipdf tutorial.dvi )
	# explorer
	( cd wekadocs/explorerguide && \
	latex guide.tex; latex guide.tex ;\
	dvipdf guide.dvi )
	# knowledgeflow
	( cd wekadocs/knowledgeflowtutorial && \
	latex tutorial.tex ; latex tutorial.tex ;\
	dvipdf tutorial.dvi )
	touch $@

install/weka-doc:: debian/stamp-install-weka-doc
debian/stamp-install-weka-doc:
	#main overview page
	install -m755 -d debian/weka-doc/usr/share/doc/weka-doc
	install -m644 documentation.css documentation.html weka.gif -t debian/weka-doc/usr/share/doc/weka-doc/
	#javadoc
	cp -r doc debian/weka-doc/usr/share/doc/weka-doc/
	#pdf's
	install -m644 wekadocs/bayesnet/bayesnet.pdf debian/weka-doc/usr/share/doc/weka-doc/BayesianNetClassifiers.pdf
	install -m644 wekadocs/explorerguide/guide.pdf debian/weka-doc/usr/share/doc/weka-doc/ExplorerGuide.pdf
	install -m644 wekadocs/experimentertutorial/tutorial.pdf debian/weka-doc/usr/share/doc/weka-doc/ExperimenterTutorial.pdf
	install -m644 wekadocs/knowledgeflowtutorial/tutorial.pdf debian/weka-doc/usr/share/doc/weka-doc/KnowledgeFlowTutorial.pdf
	touch $@

get-orig-source:
	-uscan --rename --upstream-version 0
	@echo successfully retrieved upstream tarball
